#!/usr/bin/env python3
# set coding: utf-8
"""
@Project : litewaf2
@File :    admin.py
@Time :    2023/2/24 14:41
@Author :  richard zhu
@Email :   gaotao.zhugt@dtzhejiang.com
@purpose : 
"""
from django.contrib import admin
from api.models import WafUser,WafDomain,WafRule,FlowRule,RuleGroup,Node,GlobalSetting


class WafUserAdmin(admin.ModelAdmin):
    pass

class WafDomainAdmin(admin.ModelAdmin):
    list_display = ['domain', 'status','user_id', 'port','rg_list']

class WafRuleAdmin(admin.ModelAdmin):
    list_display = ['rule_name', 'status', 'rule_type', 'rule_action', 'rule_matchs', 'uuid', 'gmt_create','gmt_modify', 'order']
    list_filter = ['rule_action', 'status']
    ordering = ['order']

class FlowRuleAdmin(admin.ModelAdmin):
    list_display = ['rule_name', 'status', 'rule_type', 'rule_action', 'action_value', 'rule_matchs', 'flow_factor_keys', 'uuid', 'gmt_create','gmt_modify', 'order']
    list_filter = ['rule_action', 'status']
    ordering = ['order']

class RuleGroupAdmin(admin.ModelAdmin):
    list_display = ['name', 'status', 'waf_rule_list', 'flow_rule_list']

class NodeAdmin(admin.ModelAdmin):
    list_display = ['hostname', 'status', 'user_id', 'ip', 'gmt_create','gmt_modify']

class GlobalSettingAdmin(admin.ModelAdmin):
    pass

admin.site.register(WafUser, WafUserAdmin)
admin.site.register(WafDomain,  WafDomainAdmin)
admin.site.register(WafRule, WafRuleAdmin)
admin.site.register(FlowRule, FlowRuleAdmin)
admin.site.register(RuleGroup, RuleGroupAdmin)
admin.site.register(Node, NodeAdmin)
admin.site.register(GlobalSetting, GlobalSettingAdmin)